package com.example.barcodeapp.ui.own.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.bumptech.glide.Glide;
import com.example.barcodeapp.R;
import com.example.barcodeapp.ui.wode.bean.kechengxiangqingBean;

import java.util.List;

public class KeChengXiangQingTuiJianAdapter extends RecyclerView.Adapter<KeChengXiangQingTuiJianAdapter.ViewHolder> {
    Context context;
    List<kechengxiangqingBean.DataEntity.TuijianEntity> list;

    public KeChengXiangQingTuiJianAdapter(Context context, List<kechengxiangqingBean.DataEntity.TuijianEntity> list) {
        this.context = context;
        this.list = list;
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View inflate = LayoutInflater.from(context).inflate(R.layout.adapter_gongkaike2, parent, false);
        return new ViewHolder(inflate);
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
        Glide.with(context).load(list.get(position).getImageurl()).into(holder.tuijiantu);
        holder.textView61.setText(list.get(position).getPrice());
        holder.tuijiankeshi.setText(list.get(position).getKeshi()+"");
    }

    @Override
    public int getItemCount() {
        return list.size();
    }


    public class ViewHolder extends RecyclerView.ViewHolder {

        private ImageView tuijiantu;
        private TextView textView61;
        private TextView tuijiankeshi;
        public ViewHolder(@NonNull View itemView) {
            super(itemView);
            tuijiantu = (ImageView) itemView.findViewById(R.id.tuijiantu);
            textView61 = (TextView) itemView.findViewById(R.id.textView61);
            tuijiankeshi = (TextView) itemView.findViewById(R.id.tuijiankeshi);
        }
    }
}
